<template>
	<view class="">
		<!-- 切换导航 -->
		<view class="nav">
			<view :class="['navList',navIndex == index ? 'navList_l':'']" 
			@tap="changeNav(index)"
			v-for="(item, index) in nav" 
			:key = "index">
				{{item}}
				<view v-if="navIndex == index" class="navList_line"></view>
			</view>	
		</view>
		<view class="" v-if="navIndex == 0">
			<!-- 海报 -->
			<image class="freeBanner" src="../../static/image/mine/index/banner.png" mode=""></image>
			<!-- 0元购商品列表 -->
			<view class="freePro_list" v-for="(item,index) in freePro" :key="index" @tap="todetail(index)">
				<image class="freePro_list_pic" src="../../static/image/mine/integral/product12.png" mode=""></image>
				<view class="freePro_list_info">
					<view class="title">
						{{item.title}}
					</view>
					<view class="bot">
						<view class="start_time">
							{{item.beganTime}}开奖
						</view>
						<view class="price">
							<view class="real_price">
								￥{{item.price}}
							</view>
							<view class="line_price">
								￥{{item.line_price}}
							</view>
						</view>
					</view>
					<view class="rightJoin">
						<image src="../../static/image/mine/new/join.png" mode=""></image>
						<view class="rightJoin_i">
							立即参加
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 我的抽奖 -->
		<view class="lotteryHistory" v-else>
			<view class="freePro_list" v-for="(item,index) in freePro" :key="index">
			<image class="freePro_list_pic" src="../../static/image/mine/integral/product12.png" mode=""></image>
			<view class="freePro_list_info">
				<view class="title">
					{{item.title}}
				</view>
				<view class="state">
					{{item.state}}
				</view>
					<view class="start_time">
						{{item.beganTime}}开奖
					</view>
					<view class="price">
						<view class="real_price">
							￥{{item.price}}
						</view>
						<view class="line_price">
							￥{{item.line_price}}
						</view>
					</view>
				<view class="rightJoin">
					<image src="../../static/image/mine/new/join.png" mode=""></image>
					<view class="rightJoin_i">
						继续抽奖
					</view>
				</view>
			</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data () {
			return {
				nav: ['全部抽奖','我的抽奖'],
				navIndex:0,
				freePro: [
					{
						pic: '../../static/image/mine/integral/product12.png',
						title: '0元抢购实惠石榴',
						beganTime: '2020-02-01 15:30',
						state: '很遗憾，您未中奖，再接再厉',
						price: '0.00',
						line_price: '199.00'
					},
					{
						pic: '../../static/image/mine/integral/product12.png',
						title: '0元抢购实惠石榴',
						beganTime: '2020-02-01 15:30',
						state: '恭喜您中奖了',
						price: '0.00',
						line_price: '199.00'
					},
					{
						pic: '../../static/image/mine/integral/product12.png',
						title: '0元抢购实惠石榴',
						beganTime: '2020-02-01 15:30',
						state: '很遗憾，您未中奖，再接再厉',
						price: '0.00',
						line_price: '199.00'
					}
				]
			}
		},
		methods: {
			changeNav (index) {
				this.navIndex = index
			},
			todetail (index) {
				uni.navigateTo({
					url: '/pageA/free/freedetail?id='+index
				})
			}
		}
	}
</script>

<style lang="less" scoped>
	.nav {
		width: 100%;
		height: 80upx;
		display: flex;
		align-items: center;
		justify-content: space-around;
		background-color: #FFFFFF;
		.navList {
			font-size: 28upx;
			color: #333333;
			position: relative;
			line-height: 28upx;
			z-index: 3;
			.navList_line {
				position: absolute;
				left: 50%;
				transform: translate(-50%);
				bottom: -7upx;
				width: 120%;
				height: 14upx;
				border-radius: 7upx;
				background-color: #fdd8d5;
				z-index: -1;
			}
		}
		.navList_l {
			color: #f73e2f,
		}
	}
	.freeBanner {
		width: 720upx;
		height: 260upx;
		margin: 20upx 15upx;
		border-radius: 10upx;
	}
	.freePro_list {
		width: calc(100% - 30upx);
		margin: auto;
		margin-bottom: 20upx;
		height: 230upx;
		background-color: #FFFFFF;
		border-radius: 10upx;
		padding: 0 15upx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		.freePro_list_pic {
			width: 176upx;
			height: 176upx;
			margin-right: 20upx;
		}
		.freePro_list_info {
			flex: 1;
			height: 176upx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			position: relative;
			.rightJoin {
				width: 167upx;
				height: 75upx;
				position: absolute;
				right: 0;
				bottom: 0;
				image {
					width: 100%;
					height: 100%;
				}
				.rightJoin_i {
					position: absolute;
					width: 120upx;
					top: 50%;
					left: 50%;
					transform: translate(-45%,-51%);
					font-size: 28upx;
					color: #FFFFFF;
				}
			}
			.title {
				font-size: 28upx;
				color: #333333;
				font-weight: bold;
			}
			.start_time {
				font-size: 24upx;
				color: #999999;
			}
			.price {
				display: flex;
				align-items: center;
				margin-top: 20upx;
			}
			.real_price {
				font-size: 28upx;
				color: #f73e2f;
			}
			.line_price {
				font-size: 24upx;
				line-height: 24upx;
				color: #666666;
				margin-left: 10upx;
				text-decoration: line-through;
			}
		}
	}
	.lotteryHistory {
		.freePro_list_info {
			justify-content: space-around;
			align-items: flex-start;
			.price {
				margin-top: 0;
			}
		}
		.state {
			font-size: 24upx;
			line-height: 40upx;
			padding: 0 20upx;
			box-sizing: border-box;
			height: 40upx;
			border-radius: 20upx;
			background-color: #f9f9f9;
		}
	}
</style>
